/* 
 * File:   PixelsTest.cpp
 * Author: max
 *
 * Created on Oct 1, 2012, 7:35:38 PM
 */

#include <stdlib.h>
#include <iostream>
#include <vector>

#include "Pixel.h"

using namespace std;

using namespace TP::Grafica;

/*
 * Simple C++ Test Suite
 */

void test1() {

    std::cout << "PixelsTest Generacion de matriz de pixels." << std::endl;
    
    // Defino el pixel por default.
    Pixel* pixelDefault = new Pixel();
    
    // Declaro la matriz de pixels.
    vector< vector <Pixel*> > pixelsA, pixelsB;
    
    // Defino la matriz de pixels A a una imagen de 3x3 y con pixeles default.
    unsigned int m = 3, n = 3;
    pixelsA.resize(m);
    for (int i = 0; i < m; i++)
    {
        pixelsA[i].resize(n);
        
        for (int j = 0; j < n; j++)
            pixelsA[i][j] = pixelDefault;
    }

    if (!(0 == pixelsA[1][1]->getR() && 0 == pixelsA[1][1]->getG() && 0 == pixelsA[1][1]->getB()))
        std::cout << "%TEST_FAILED% time=0 testname=matriz de pixels (PixelsTest) message=el pixel obtenido no es el esperado." << std::endl;
    
    delete pixelDefault;
    
}

void test2() {

    std::cout << "PixelsTest Seteo de pixel (1,2) a (1,2,3)." << std::endl;
    
    // Defino el pixel por default.
    Pixel* pixelDefault = new Pixel();
    
    // Declaro la matriz de pixels.
    vector< vector <Pixel*> > pixelsA;
    
    // Defino la matriz de pixels A a una imagen de 3x3 y con pixeles default.
    unsigned int m = 3, n = 3;
    pixelsA.resize(m);
    for (int i = 0; i < m; i++)
    {
        pixelsA[i].resize(n);
        
        for (int j = 0; j < n; j++)
            pixelsA[i][j] = pixelDefault;
    }
    
    pixelsA[1][2] = new Pixel (1,2,3);

    if (!(1 == pixelsA[1][2]->getR() && 2 == pixelsA[1][2]->getG() && 3 == pixelsA[1][2]->getB()))
        std::cout << "%TEST_FAILED% time=0 testname=matriz de pixels (PixelsTest) message=el pixel obtenido no es el esperado (1,2,3)." << std::endl;
    
    for (int i = 0; i < m; i++)
        for (int j = 0; j < n; j++)
            if (pixelsA[i][j] != pixelDefault)
                delete pixelsA[i][j];
    
    
    delete pixelDefault;
    
}


int main(int argc, char** argv) {
    std::cout << "%SUITE_STARTING% PixelsTest" << std::endl;
    std::cout << "%SUITE_STARTED%" << std::endl;

    std::cout << "%TEST_STARTED% test1 (PixelsTest)" << std::endl;
    test1();
    std::cout << "%TEST_FINISHED% time=0 test1 (PixelsTest)" << std::endl;

    std::cout << "%TEST_STARTED% test2 (PixelsTest)\n" << std::endl;
    test2();
    std::cout << "%TEST_FINISHED% time=0 test2 (PixelsTest)" << std::endl;

    std::cout << "%SUITE_FINISHED% time=0" << std::endl;

    return (EXIT_SUCCESS);
}

